import http from '@/api'
import { ADMIN_MODULE } from '@/api/helper/prefix'
import type { IPage } from '@/api/types';
import type { LifeDayQuery, LifeDayRow, LifeDayForm } from '@/api/types/life/lifeDay'
import type { UploadRawFile } from "element-plus/es/components/upload/src/upload";
import type { AxiosRequestConfig } from 'axios';

/**
* 查询列表
* @param params
* @returns {*}
*/
export const getLifeDayListApi = (params: LifeDayQuery) => {
  return http.get<IPage<LifeDayRow>>(ADMIN_MODULE + `/life-day`, params)
}

/**
* 添加
* @param params
* @returns {*}
*/
export const createLifeDayApi = (params: LifeDayForm) => {
  return http.post(ADMIN_MODULE + `/life-day`, params)
}

/**
* 新增一天数据
*/
export const createOneLifeDayApi = (params: LifeDayForm) => {
  return http.post(ADMIN_MODULE + `/life-day/create`, params)
}

/**
* 修改图片
*/
export const changeOneLifePictureApi = (params: LifeDayForm) => {
  return http.post(ADMIN_MODULE + `/life-day/changePicture`, params)
}

/**
*  获取近7天数据
*/
export const getOneLifeDayListApi = (params: LifeDayForm) => {
  return http.get(ADMIN_MODULE + `/life-day/list`, params)
}

/**
* 修改
* @param params
* @returns {*}
*/
export const updateLifeDayApi = (params: LifeDayForm) => {
  return http.put(ADMIN_MODULE + `/life-day`, params)
}

/**
* 删除
* @param params
* @returns {*}
*/
export const removeLifeDayApi = (params: { ids: (string | number)[] }) => {
 return http.delete(ADMIN_MODULE + `/life-day`, params)
}

/**
* 获取详情
* @param params
* @returns {*}
*/
export const getLifeDayDetailApi = (params: { id: number }) => {
  const { id } = params
  return http.get<LifeDayRow>(ADMIN_MODULE + `/life-day/${id}`)
}

/**
* 导入excel
* @param params
*/
export const importLifeDayExcelApi = (params : UploadRawFile, config?: AxiosRequestConfig<any> | undefined) => {
  return http.upload(ADMIN_MODULE + `/life-day/import`, params, config)
}

/**
* 导出excel
* @param params
* @returns {*}
*/
export const exportLifeDayExcelApi  = (params: LifeDayQuery) => {
  return http.download(ADMIN_MODULE + `/life-day/export`, params)
}